﻿using T4UtilityBelt.DataDesigns;
using T4UtilityBelt.Writers;

namespace T4UtilityBelt.UxDesigns.Controls.Renderers.Windows
{
    public class StringRenderer : PropertyRenderer<StringControl, IStringRenderer, StringProperty>, IStringRenderer
    {
        protected override void OnRenderUiXmlContentInput(StringControl control, CodeWriter writer)
        {
            // <TextBox  Controls:HelpText.Text="<#=name#>tt" Text="{Binding  Entry.<#=name#>,  Mode=TwoWay}" />
            writer.WriteBeginTag("TextBox");
            RenderControlAttributes(control, writer);
            writer.WriteAttribute("AcceptsReturn", control.AcceptsReturn, false);

            writer.AddBinding("Text", control.Text);

            //writer.WriteAttributeFormat("Text", @"{{Binding {0},  Mode=TwoWay}}", GetBindingContext(control));

            writer.WriteFullEnd();
        }

        protected override void OnRenderUiXmlContentReadOnly(StringControl control, CodeWriter writer)
        {
            //<TextBlock  Text="{Binding  Entry.<#=name#>}" />
            writer.WriteBeginTag("TextBlock");

            //if (control.Style == null)
            //{
            //    writer.WriteAttribute("Style", "{StaticResource ReadonlyTextBlock}");
            //}
            //else
            //{
            //   writer.WriteAttributeFormat("Style", @"{{StaticResource {0}}}", control.Style);
            //}
            writer.AddBinding("Text", control.Text);

            writer.WriteFullEnd();
        }
    }
}